﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InfoReadView.aspx.cs" Inherits="InfoReadView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title></title>
	<script src="Script/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
	<script type="text/javascript" language="javascript" >
	    function json2string(strObject) {
	        var c, i, l, s = '', v, p;

	        switch (typeof strObject) {
	            case 'object':
	                if (strObject) {
	                    if (strObject.length && typeof strObject.length == 'number') {
	                        for (i = 0; i < strObject.length; ++i) {
	                            v = json2string(strObject[i]);
	                            if (s) {
	                                s += ',';
	                            }
	                            s += v;
	                        }
	                        return '[' + s + ']';
	                    } else if (typeof strObject.toString != 'undefined') {
	                        for (i in strObject) {
	                            v = strObject[i];
	                            if (typeof v != 'undefined' && typeof v != 'function') {
	                                v = json2string(v);
	                                if (s) {
	                                    s += ',';
	                                }
	                                s += json2string(i) + ':' + v;
	                            }
	                        }
	                        return '{' + s + '}';
	                    }
	                }
	                return 'null';
	            case 'number':
	                return isFinite(strObject) ? String(strObject) : 'null';
	            case 'string':
	                l = strObject.length;
	                s = '"';
	                for (i = 0; i < l; i += 1) {
	                    c = strObject.charAt(i);
	                    if (c >= ' ') {
	                        if (c == '\\' || c == '"') {
	                            s += '\\';
	                        }
	                        s += c;
	                    } else {
	                        switch (c) {
	                            case '\b':
	                                s += '\\b';
	                                break;
	                            case '\f':
	                                s += '\\f';
	                                break;
	                            case '\n':
	                                s += '\\n';
	                                break;
	                            case '\r':
	                                s += '\\r';
	                                break;
	                            case '\t':
	                                s += '\\t';
	                                break;
	                            default:
	                                c = c.charCodeAt();
	                                s += '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
	                        }
	                    }
	                }
	                return s + '"';
	            case 'boolean':
	                return String(strObject);
	            default:
	                return 'null';
	        }
	    }
	</script>
	<script type="text/javascript" language="javascript">
	    var GATButton = function() {
	        var GATTextArticleID = document.getElementById("GATTextArticleID").value;
	        var formative = { "ArticleID": GATTextArticleID };
	        var jsonStr = json2string(formative);
	        $.ajax({
	            type: "POST",
	            url: "http://localhost:9162/InfoReadBLLService.svc/GetArticleTitle",
	            contentType: "application/json;charset=utf-8",
	            data: jsonStr,
	            success: function(data) {
	                var GATTextArticleTitle = document.getElementById("GATTextArticleTitle");
	                GATTextArticleTitle.value = data;

	            },
	            error: function(XMLHttpRequest, textStatus, errorThrown) {
	                alert("获取文章题目错误！");
	            },
	            cache: false
	        });
	    }
	</script>
	<script type="text/javascript" language="javascript">
	    function GATL1Button() {
	        $('#GATL1Div').html("");
	        var text = document.getElementById("GATL1TextWherestring").value;
	        var formativeData = { "wherestring": text };
	        var jsonStr = json2string(formativeData);
	        $.ajax({
	            type: "POST",
	            url: "http://localhost:9162/InfoReadBLLService.svc/GetArticleTitleList1",
	            contentType: "application/json;charset=utf-8",
	            data: jsonStr,
	            success: function(data) {
	                var div = document.getElementById("GATL1Div");
	                div.innerHTML += "<table>";
	                div.innerHTML += "<tr>";
	                div.innerHTML += "<td>文章ID</td><td>模块名</td><td>标题</td><td>内容</td>";
	                div.innerHTML += "<td>Abstract</td><td>AddTime</td>";
	                div.innerHTML += "</tr>";
	                $.each(data, function(i) {
	                    if (i > 30) return;
	                    div.innerHTML += "<tr>";
	                    div.innerHTML += "<td>" + data[i].ArticleID + "</td>";
	                    div.innerHTML += "<td>" + data[i].ModuleName + "</td>";
	                    div.innerHTML += "<td>" + data[i].Title + "</td>";
	                    div.innerHTML += "<td>" + data[i].Content + "</td>";
	                    div.innerHTML += "<td>" + data[i].Abstract + "</td>";
	                    div.innerHTML += "<td>" + data[i].addTime + "</td>";
	                    div.innerHTML += "</tr>";
	                });
	            },
	            error: function() {
	                alert("error");
	            },
	            cache: false
	        });

	    }
	</script>
	<script type="text/javascript" language="javascript">
	    function GATL2Button() {
	        $('#GATL2Div').html("");
	        var text = document.getElementById("GATL2TextWherestring").value;
	        var formativeData = { "wherestring": text };
	        var jsonStr = json2string(formativeData);
	        $.ajax({
	            type: "POST",
	            url: "http://localhost:9162/InfoReadBLLService.svc/GetArticleTitleList2",
	            contentType: "application/json;charset=utf-8",
	            data: jsonStr,
	            success: function(data) {
	                var div = document.getElementById("GATL2Div");
	                div.innerHTML += "<table>";
	                div.innerHTML += "<tr>";
	                div.innerHTML += "<td>文章ID</td><td>标题</td><td>内容</td>";
	                div.innerHTML += "<td>Abstract</td><td>AddTime</td>";
	                div.innerHTML += "</tr>";
	                $.each(data, function(i) {
	                    if (i > 30) return;
	                    div.innerHTML += "<tr>";
	                    div.innerHTML += "<td>" + data[i].ArticleID + "</td>";
	                    div.innerHTML += "<td>" + data[i].Title + "</td>";
	                    div.innerHTML += "<td>" + data[i].Content + "</td>";
	                    div.innerHTML += "<td>" + data[i].Abstract + "</td>";
	                    div.innerHTML += "<td>" + data[i].addTime + "</td>";
	                    div.innerHTML += "</tr>";
	                });
	            },
	            error: function(XMLHttpRequest) {
	                alert("error");
	            },
	            cache: false
	        });

	    }
	</script>
	<script type="text/javascript" language="javascript">
	    function GCELButton() {
	        $('#GCELDiv').html("");
	        var text = document.getElementById("GCELTextGroupid").value;
	        var formativeData = { "groupid": text };
	        var jsonStr = json2string(formativeData);
	        $.ajax({
	            type: "POST",
	            url: "http://localhost:9162/InfoReadBLLService.svc/GetCustomerEmailList",
	            contentType: "application/json;charset=utf-8",
	            data: jsonStr,
	            success: function(data) {
	                var div = document.getElementById("GCELDiv");
	                alert(data[0]);
	                div.innerHTML += "<table>";
	                div.innerHTML += "<tr>";
	                div.innerHTML += "<td>客户姓名</td><td>Email</td><td>组ID</td>";
	                div.innerHTML += "</tr>";
	                $.each(data, function(i) {
	                    if (i > 30) return;
	                    div.innerHTML += "<tr>";
	                    div.innerHTML += "<td>" + data[i].Customename + "</td>";
	                    div.innerHTML += "<td>" + data[i].Email + "</td>";
	                    div.innerHTML += "<td>" + data[i].GroupId + "</td>";
	                    div.innerHTML += "</tr>";
	                });
	            },
	            error: function(XMLHttpRequest, textStatus, errorThrown) {
	                alert("error");
	            },
	            cache: false
	        });

	    }
	</script>
</head>
<body>
	<form id="form1" runat="server">
	<!--获取文章的标题-->
	<div id="GetArticleTitle">
		文章ID：
		<input id="GATTextArticleID" type="text" />
		<input type="button" value="提交" onclick="GATButton()" />
		文章标题：
		<input id="GATTextArticleTitle" type="text" />
	</div>
	<!--获取文章列表1 显示模块名称-->
	<div id="GetArticleTitleList1">
	    <asp:Label Text="获取文章列表1 查询模块的名字" runat="server"></asp:Label><br/>
	    输入Where子句条件：
	    <input id="GATL1TextWherestring" type="text" />
	    <input type="button" value="Call" onclick="GATL1Button()" />
	    <div id="GATL1Div"></div>
	</div>
	<!--获取文章列表2 不显示模块名称-->
	<div id="GetArticleTitleList2">
	    <asp:Label Text="获取文章列表2 不查询模块的名字" runat="server"></asp:Label><br />
	    输入Where子句条件:
	    <input id="GATL2TextWherestring" type="text" />
	    <input type="button" value="Call" onclick="GATL2Button()" />
	    <div id="GATL2Div"></div>
	</div>
	<!--获取客户名称和Email列表-->
	<div id="GetCustomerEmailList">
	    <asp:Label Text="获取客户名称和Email列表" runat="server"></asp:Label><br />
	    输入组ID：
	    <input id="GCELTextGroupid" type="text" />
	    <input type="button" value="Call" onclick="GCELButton()" />
	    <div id="GCELDiv"></div>
	</div>
	</form>
</body>
</html>
